Copy heading to attribute

I'm importing a word document into doors that has the version number (in text format) above the requirement object. Both are imported as separate objects. I need a way to move the version number into a text based attribute of its partner requirement.
Is there a way of doing this either in pre-processing in Word or by some sort of "find and move to attribute" DXL in DOORS?
NBowick - Wed Feb 16 06:59:29 EST 2011

Re: Copy heading to attribute
llandale - Wed Feb 16 16:44:46 EST 2011

Word Imports support the notion of a hierarchy spec, but you can only import from Word into Object Heading or Text. Excel Imports support the notion of an attributed spread sheet, you can import into multiple attributes, but you cannot define the Hierarchy of your module in this way. Pick your poison.

With the exception of End-Of-Lines inside Word table cells, all EOLs in the word document delimit where the newly created DOORS objects will go. You can get your Version and your Text into the same object by removing the EOL that is between them, possibly replacing them with an LF character. In Word, EOL is created with the "Enter" key, LF with the shft-Enter key. Before importing its highly advantageous to view all these special characters, including TABs.

If your "Version" string had an unambigous format that a dumb program could recognize, then it would not be hard to do the following:
<1> Replace EOL with LF after your Version number
<2> Import into DOORS
<3> Write a DXL that reads Object Text, and when it finds the first line contains a Version Number then it extracts that Version Number and sets some "VersionNumber" string attribute, and updates the Text.

There are folks here much better at Regular Expressions than I am, but you could write this DOORS function:

Regexp  reVersion1 = regexp2("^(versFormat1)(\\n)(.*)$") // one possible format of Version,
        reVersion2 = regexp2("^(versFormat2)(\\n)(.*)$") // next possible format
 
string  NameAttrVersion = "VersionImport"
 
bool    UpdateVersion(Object obj)
{       // if the object Text contains a Version string in its first line and the Version attribute does not,
        //    then remove the Version from the Text and update the Version Attribute.
        // Object text must not contain rich text nor OLE (actually, rich text and OLE is removed when
        //    version is updated)
        // Return whether the objects was updated or not
 
    if (null obj)     return(false)
    if (!null probeAttr_(obj, NameAttrVersion)   return(false)
 
    string  Text = probeAttr_(obj, "Object Text")
    if (reVersion1 Text   or
        reVersion2 Text)
    {               // Version String Found
       obj.NameAttrVersion = Text[match 1]
       obj."Object Text"   = Text[match 3]
       return(true)
    }
    else
    {  return(false)
    }
}   // end UpdateVersion()


Someone will finish that if you tell us what your Version strings look like, perhaps "v3.1.1". Needs to be tested with Text that has multiple EOLs therein, including Version strings not as the first line.

Function needs work to strip off the Version but otherwise preserving rich text and OLE diagrams, that's actually pretty tricky.

 

 

  • Louie


There are guides for formatting Word files for suitable import; one method is to save-as RTF which resolves most of the problems.

 

 

Re: Copy heading to attribute
SystemAdmin - Wed Feb 16 17:32:25 EST 2011

Just elaborating on pre-processing in Word as an alternative to post processing in DOORS.

You need to move (cut-n-paste) the Version Number text into the same paragraph as the associated requirement text. Place it at the very beginning of the para but include a delimiter character of some sort so that it separates the Version Number text from the Requirements text. Ideally, use a unique character as the delimiter, something that is not used in the document.

For example - two para's:

Version XYZ
The system shall blah blah blah.

Becomes a single para with a # delimiter:

Version XYZ#The system shall blah blah blah.

If the syntax of your version text is predictable, you can take advantage of MSWords find&Replace feature in conjunction with regular expressions to avoid doing it manually. VBA scripting would also be useful if it requires a more sophisticated approach.

Export the Word document to DOORS.

Create a DXL script that can chomp out the Version Text up to and including the delimiter and copy it to a specified string attribute of your choice (have attached an example) - the script looks for the delimiter in the Object Text attribute of each Object and if found, copy the preceding characters into a buffer, remove the characters and the delimiter from the Object Text, copy the contents of the buffer to a specified attribute of the current object. If you know that the version text cannot be any longer than a certain number of characters, then only search that far into the Object Text for the delimiter. If your requirements have rich text formatting such as bold, italics etc, you'll need to use DXL RTF library functions to execute the chomp so that no RTF is lost.

I've attached a DXL script I have used in the past to do something like this, it assumes no RTF has been used, might give you some ideas or you can modify to suit.


Paul Miller
Melbourne, Australia
Attachments

attachment_14583860__ExtractAndReplaceString.dxl

Re: Copy heading to attribute
PDU - Thu Feb 17 01:59:32 EST 2011

SystemAdmin - Wed Feb 16 17:32:25 EST 2011
Just elaborating on pre-processing in Word as an alternative to post processing in DOORS.

You need to move (cut-n-paste) the Version Number text into the same paragraph as the associated requirement text. Place it at the very beginning of the para but include a delimiter character of some sort so that it separates the Version Number text from the Requirements text. Ideally, use a unique character as the delimiter, something that is not used in the document.

For example - two para's:

Version XYZ
The system shall blah blah blah.

Becomes a single para with a # delimiter:

Version XYZ#The system shall blah blah blah.

If the syntax of your version text is predictable, you can take advantage of MSWords find&Replace feature in conjunction with regular expressions to avoid doing it manually. VBA scripting would also be useful if it requires a more sophisticated approach.

Export the Word document to DOORS.

Create a DXL script that can chomp out the Version Text up to and including the delimiter and copy it to a specified string attribute of your choice (have attached an example) - the script looks for the delimiter in the Object Text attribute of each Object and if found, copy the preceding characters into a buffer, remove the characters and the delimiter from the Object Text, copy the contents of the buffer to a specified attribute of the current object. If you know that the version text cannot be any longer than a certain number of characters, then only search that far into the Object Text for the delimiter. If your requirements have rich text formatting such as bold, italics etc, you'll need to use DXL RTF library functions to execute the chomp so that no RTF is lost.

I've attached a DXL script I have used in the past to do something like this, it assumes no RTF has been used, might give you some ideas or you can modify to suit.


Paul Miller
Melbourne, Australia

Hi,

if word document use styles for each part of the requirements (identifier, version, texte, etc.), it is very efficient do post processing using 'paragraph style' attribut.

Pierre

Re: Copy heading to attribute
NBowick - Thu Feb 17 06:28:01 EST 2011

Thanks for your replies, guys. Paul, I've edited your code to work with what I'm trying to do. SO far so good. The delimiter idea is great. I'm trying to get the code to move the data after the delimiter into an attribute of the next object. Eg if the objects look like:

Version number
Requriement

Then I would like the version number to become an attribute of the requirement. I'm trying to use the "nextObj" code to do this, but I'm not making much progress. Any ideas?

Re: Copy heading to attribute
NBowick - Thu Feb 17 08:24:55 EST 2011

Scratch that, got it up and running after all. Thanks very much for your input guys!